<template>
  <div id='qx'>
    222
  </div>
</template>

<script>
export default {
  data: {
    return: {
      title_children_lists: [],
      primarynum: 1,
      leibie_lis_zcid: '100',
    },
  },
  created() {
    
  },
  methods: {
    title_children_list() {
      this.$axios.get('/info/ContractBFj/getCategory').then((res) => {
        if (res.data.data) {
          this.title_children_lists = res.data.data
          this.suoyoufujian()
        }
      })
    },
    suoyoufujian() {
      this.$axios
        .post('/info/ContractBFj/getList', {
          type: this.primarynum,
          cglxId: this.leibie_lis_zcid,
        })
        .then((res) => {
          console.log(res)
          if (res.data.data) {
            console.log(this.title_children_lists)
            this.title_children_lists = [
              { name: '', fjflid: '', children: res.data.data },
            ]
            let aa = []
            res.data.data.forEach((rs) => {
              if (rs.relation == '1') {
                aa.push(rs.id)
              }
              this.$set(this.relationarr, 0, aa)
            })
            console.log(this.title_children_lists)
            
            for (let i in this.title_children_lists) {
              let children = []
              let relation = []
              this.title_children_lists[i].children = []
              res.data.data.forEach((hmp) => {
                if (this.title_children_lists[i].fjflid == hmp.fjflid - 0) {
                  children.push(hmp)
                  if (hmp.relation == '1') {
                    relation.push(hmp.id)
                  }
                  this.$set(this.relationarr, i, relation)
                  
                  this.title_children_lists[i].relation = relation
                  this.title_children_lists[i].children = children
                } else {
                }
              })
            }
            console.log(this.title_children_lists)
          }
          
        })
    },
  },
}
</script>

<style>
</style>